package cli;

import java.util.Scanner;

public class InputWidget {
	private String prompt;
	private Scanner scanner = new Scanner(System.in);
	
	public InputWidget(String prompt) {
		this.prompt = prompt;
	}
	
	public String promptForString() {
		System.out.println(this.prompt);
		String input = this.scanner.nextLine();
		System.out.println();
		
		return input;
	}
	
	public int promptForInteger() {
		System.out.println(this.prompt);
		
		try {
			Integer input = Integer.parseInt(this.scanner.nextLine());
			System.out.println();
			return input;
		}
		catch (NumberFormatException e) {
			System.out.println("Please use numerical characters only (0 through 9).");
			return this.promptForInteger();
		}
	}
}
